<template>
  <view
    class="SearchPeopleItem animate__animated animate__bounceInRight"
    @click="handleSkipToUser"
  >
    <image :src="userDetail.avatar" class="avatar" />
    <view class="peopleInfo">
      <view class="peopleName">{{ userDetail.nickName }}</view>
      <view class="introduce">{{ userDetail.introduce }}</view>
      <view class="tags">
        <van-tag
          plain
          size="medium"
          class="tag"
          v-for="(i, index) in userDetail.tags"
          :key="index"
          >{{ i }}</van-tag
        >
      </view>
    </view>
    <view class="operator" v-if="showOperator">
      <van-button
        block
        size="small"
        color="#05A47D"
        class="btn"
        @click.stop="handleInvite"
        >邀请加入</van-button
      >
    </view>
  </view>
</template>

<script>
export default {
  name: "SearchPeopleItem",
  props: {
    userDetail: {
      type: Object,
    },
    showOperator: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {};
  },
  methods: {
    handleInvite() {
      this.$emit("invitePeople", this.userDetail._openid);
    },

    handleSkipToUser() {
      uni.navigateTo({
        url: `/pages/UserInfo/UserInfo?userDetail=${encodeURIComponent(
          JSON.stringify(this.userDetail)
        )}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.SearchPeopleItem {
  padding: 20rpx 0;
  margin-bottom: 10rpx;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  border-bottom: 1rpx solid #eee;
  .avatar {
    width: 100rpx;
    height: 100rpx;
    border-radius: 50%;
    margin-right: 20rpx;
  }
  .peopleInfo {
    flex: 1;
    .introduce {
      margin: 10rpx 0;
      width: 400rpx;
      color: #aaa;
      font-size: 26rpx;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .tags {
      display: flex;
      .tag {
        margin-right: 10rpx;
      }
    }
  }
  .operator {
    margin-left: 20rpx;
  }
}
</style>
